/**
 * @Author：JIAMIN_TANG
 * @Description:
 * @CreateTime：2025/9/25 20:23
 */
public class Solution {
    public int countSegments(String s){
        String[] words = s.trim().split("\\s+");
        int count = 0;

        for(String word:words){
            if(!word.isEmpty()){
                count++;
            }
        }
        return count;
    }
    public static void main(String[] args){
        Solution solution = new Solution();
        String s = "Hello,my name is john";
        int result = solution.countSegments(s);
        System.out.print(result);
    }
}
